package model.quiz
{
	import laya.events.Event;
	import laya.utils.Handler;
	
	import script.ViewManager;
	import script.baseView.BaseViewController;
	import script.quizview.item.QuestionResultCell;
	
	import ui.quiz.QuizResultPanelUI;
	
	public class MathQuizResultController extends BaseViewController
	{
		
		private var uiSkin:QuizResultPanelUI;

		public function MathQuizResultController()
		{
			super();
		}
		
		override public function onStart():void
		{
			uiSkin = this.owner as QuizResultPanelUI;
			
			uiSkin.questionList.itemRender = QuestionResultCell;
			
			//uiSkin.orderList.vScrollBarSkin = "";
			uiSkin.questionList.repeatX = 1;
			uiSkin.questionList.spaceY = 10;
			
			uiSkin.questionList.renderHandler = new Handler(this, updateQuestionlist);
			uiSkin.questionList.selectEnable = false;
			uiSkin.questionList.array = [];
			
			this.uiSkin.scoretxt.text = MathQuizModel.instance.score + "";
			
			uiSkin.rightnumanswer.text = MathQuizModel.instance.rightnum + "";
			
			uiSkin.wrongnum.text = (MathQuizModel.instance.questionNum - MathQuizModel.instance.rightnum) + "";
			
			uiSkin.questionList.array = MathQuizModel.instance.questionList;
			
			uiSkin.okbtn.on(Event.CLICK,this,closeView);
			
		}
		
		private function closeView():void
		{
			ViewManager.instance.closeView(ViewManager.VIEW_MATHQUIZ_RESULT_PANEL);
		}
		public function updateQuestionlist(cell:QuestionResultCell):void
		{
			cell.setData(cell.dataSource);
		}
		
	}
}